﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Core
{
    public static class ArgumentExtension
    {
        public static string NullNumber(this int? i)
        {
            return i == null ? "null" : i.ToString();
        }
        public static string NullDate(this DateTime? dt)
        {
            return dt == null ? "null" : String.Format("'{0}'", dt.Value.ToString("yyyy-MM-dd HH:mm:ss.hhh"));
        }
        public static string StringDate(this DateTime dt)
        {
            return String.Format("'{0}'", dt.ToString("yyyy-MM-dd HH:mm:ss.hhh"));
        }
        public static string NullString(this string str)
        {
            return string.IsNullOrWhiteSpace(str) ? "null" : String.Format("'{0}'", str.Replace("'", "''"));
        }
    }
}
